package smartlifev30.com.sdk.api.service_app;

import android.support.annotation.NonNull;

import smartlifev30.com.sdk.util.JsonUtil;
import smartlifev30.com.sdk.api.CallBack;
import smartlifev30.com.sdk.bean.request.Heartbeat2ServerRequest;
import smartlifev30.com.sdk.bean.response.HeartbeatResponse;
import smartlifev30.com.sdk.net.baiwei.NetManager;
import smartlifev30.com.sdk.net.baiwei.ResponseHelper;

/**
 * Created by tys on 2018/8/12.
 */

public class HeartbeatImpl implements IHeartbeat {
    @Override
    public void hearBeat2Server(@NonNull String userName, @NonNull String token, @NonNull CallBack<HeartbeatResponse> callBack) {
        Heartbeat2ServerRequest heartbeat2ServerRequest = new Heartbeat2ServerRequest();
        heartbeat2ServerRequest.setFrom(userName);
        heartbeat2ServerRequest.setMsg_id(callBack.getMsgId());
        heartbeat2ServerRequest.setMsg_class("app_common");
        heartbeat2ServerRequest.setMsg_name("app_heartbeat");
        heartbeat2ServerRequest.setMsg_type("get");
        heartbeat2ServerRequest.setToken(token);
        NetManager.getInstance().sendMessage(JsonUtil.toString(heartbeat2ServerRequest));
        ResponseHelper.addListen(callBack);
    }
}
